package cn.joeg.dp.prototype;

import java.io.*;
import java.util.List;

public class Cell implements Cloneable,Serializable{


    private static final long serialVersionUID = -7917208078809174182L;

    private int size;
    private String name;
    private List<Protein> proteinList;

    @Override
    public Cell clone() throws CloneNotSupportedException {
        return (Cell) super.clone();
    }


    public Cell deepClone(){
        ByteArrayOutputStream bos = null;
        ObjectOutputStream oos = null;
        ByteArrayInputStream bis = null;
        ObjectInputStream ois = null;

        try {
            bos = new ByteArrayOutputStream();
            oos = new ObjectOutputStream(bos);
            oos.writeObject(this);


            bis = new ByteArrayInputStream(bos.toByteArray());
            ois = new ObjectInputStream(bis);
            return (Cell) ois.readObject();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }finally {
            try {
                if (null!= bos){
                    bos.close();
                }

                if (null!= oos){
                    oos.close();
                }

                if (null!= bis){
                    bis.close();
                }

                if (null!= ois){
                    ois.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
            return null;
    }



    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Protein> getProteinList() {
        return proteinList;
    }

    public void setProteinList(List<Protein> proteinList) {
        this.proteinList = proteinList;
    }
}
